#include "ServerUdp.h"
#include "ServerTcp.h"
#include "Process.h"

namespace tsc
{
namespace common
{

using namespace std;
using namespace boost::asio;

/*******************************************************************************
 *
 * Constructor
 *
 ******************************************************************************/
Process::Process(io_service* pIoService)
  : mpIoService(pIoService)
{
  mUdpServers.clear();
  mTcpServers.clear();
  InitProcess();
} // Process::Process

/*******************************************************************************
 *
 * Destructor
 *
 ******************************************************************************/
Process::~Process()
{
  for(list<ServerUdp*>::iterator Iter = mUdpServers.begin();
      Iter != mUdpServers.end(); Iter++)
  {
    delete (*Iter);
  }
  mUdpServers.clear();

  for(list<ServerTcp*>::iterator Iter = mTcpServers.begin();
      Iter != mTcpServers.end(); Iter++)
  {
    delete (*Iter);
  }
  mTcpServers.clear();

} // Process::~Process

/*******************************************************************************
 *
 * Register UDP Server
 *
 ******************************************************************************/
void Process::RegisterServer(ServerUdp* pServer)
{
  mUdpServers.push_back(pServer);
} // Process::RegisterServer

/*******************************************************************************
 *
 * Register TCP Server
 *
 ******************************************************************************/
void Process::RegisterServer(ServerTcp* pServer)
{
  mTcpServers.push_back(pServer);
} // Process::RegisterServer

/*******************************************************************************
 *
 * Initiate process
 *
 ******************************************************************************/
void Process::InitProcess()
{
  RegisterServers();
} // Process::InitProcess

} // namespace common
} // namespace tsc
